package cn.edu.zafu.bigdata.x.sxy;

import java.util.Random;
import java.util.Scanner;

public class GuessTheNumbers {
    private static final Random random = new Random();
    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int numberToGuess = random.nextInt(100) + 1; // 生成一个1到100之间的随机数
        int maxTries = 8; // 玩家有8次机会
        System.out.println("猜数字游戏开始！我已经想好了一个1到100之间的数字。你有" + maxTries + "次机会猜中它。");

        for (int tries = 1; tries <= maxTries; tries++) {
            System.out.print("猜一猜: ");
            int guess = scanner.nextInt();

            if (guess == numberToGuess) {
                System.out.println("恭喜你！你猜对了，数字为 " + numberToGuess);
                break;
            } else if (guess < numberToGuess) {
                System.out.println("细狗太小了！");
            } else {
                System.out.println("倒三角太大了！");
            }

            if (tries == maxTries) {
                System.out.println("你太菜了，我想的数字是 " + numberToGuess);
            }
        }

        System.out.println("Game Over!");
    }
}